package com.cn.cs;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import java.sql.DriverManager;

//删除、
public class dome3 {
    public static void main(String[] args) {
        try {
            //第一步加载驱动jar
            Class.forName("com.mysql.jdbc.Driver");
            //获取数据库的连接对象
            Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql1","root","root");
            //获取发送sql的对象
            PreparedStatement pst = (PreparedStatement) con.prepareStatement("delete from bbb where id=?");
            //解析占位符
            pst.setInt(1, 111);
            //执行sql获取结果
            int count = pst.executeUpdate();
            System.out.println(count > 0 ? "操作成功" : "操作失败");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
